package service.impl;

import dao.AccountDao;
import entity.Account;
import service.LoanService;
import util.DaoFactory;

public class LoanServiceImpl implements LoanService {

	@Override
	public double apply(String account, double amount) throws Exception {
		double money=-1;
		AccountDao dao = DaoFactory.getInstance(AccountDao.class);
		Account a=dao.findByAccount(account);
		if(a!=null){
			if(a.getBalance()*2>amount){
				money=amount;
			}else{
				money=-2;
			}
		}
		return money;
	}

}
